<template>
	<view class="wf-box" :style="{ paddingTop: totalheight }">
		<HeadNav titleName="助记词安全备份提醒" :topheight="navBarHeight"></HeadNav>

		<view class="main">
			<view class="main-ctr">
				<image src="../../static/img/me-56.png" class="secure-img"></image>
				<view class="sce-pd">
					<view class="sce-item">
						<view class="sce-tit">1.离线保存</view>
						<view class="sce-txt">切勿保存至邮箱、记事本、网盘、聊天工具等中心化软件， 一旦被访问助记词内容非常危险，建议用纸笔按顺序抄写
							记录（注意字母大小写），并保存至安全的地方。</view>
					</view>

					<view class="sce-item">
						<view class="sce-tit">2.切勿使用网络传输</view>
						<view class="sce-txt">请勿通过网络工具传输私钥，一旦被黑客获取将造成不可 挽回的资产损失。</view>
					</view>

					<view class="sce-item">
						<view class="sce-tit">3.安全提示</view>
						<view class="sce-txt">此为去中心化APP，永远不会询问您的助记词</view>
					</view>

					<view class="sce-footer" @click="openPopup()">
						备份我的钱包
					</view>
				</view>

			</view>
		</view>

		<uni-popup ref="popup" type="center">
			<view class="popup-box">
				<view class="popup-title">请输入密码</view>
				<view class="popup-sub">
					<view>
						<input type="password" placeholder="请输入钱包密码" v-model="password">
					</view>
				</view>
				<view class="popup-footer">
					<view class="cancle" @click="closePopup()">取消</view>
					<view class="confim" @click="confim">确认</view>
				</view>
			</view>
		</uni-popup>

	</view>
</template>

<script>
	import { throttle } from '@/utils/common.js'
	import { checkPsdApi } from '@/api/api.js'
	import HeadNav from "@/components/HeadNav"
	import navBarMixin from '@/mixin/navBarMixin.js'
	export default {
		data() {
			return {}
		},
		mixins: [navBarMixin],
		components: {
			HeadNav
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			openPopup() {
				this.$refs.popup.open()
			},
			closePopup() {
				this.$refs.popup.close()
			},

			confim() {
				throttle(async () => {
					const res = await checkPsdApi({
						password: this.password
					})
					if (!res.code) {
						const words = res.data.result

						uni.navigateTo({
							url: '/pages/me/meAid?wordArr=' + JSON.stringify(words)
						})
						this.closePopup()

					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				}, 4000)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wf-box {
		padding-bottom: 60rpx;
		overflow: hidden;

		.main {
			padding: 0 30rpx;
			margin-top: 30rpx;

			.main-ctr {
				min-height: 1348rpx;
				padding-top: 90rpx;
				box-sizing: border-box;
				border-radius: 10rpx;
				background: #fff;

				.secure-img {
					width: 100%;
				}

				.sce-pd {
					padding: 0 30rpx;
					margin-top: 30rpx;

					.sce-item {
						margin-top: 30rpx;

						.sce-tit {
							color: $theme-color-a;
							font-size: 28rpx;
						}

						.sce-txt {
							color: #999;
							margin-top: 20rpx;
							font-size: 24rpx;
						}
					}

					.sce-footer {
						height: 80rpx;
						line-height: 80rpx;
						margin-top: 120rpx;
						background: $theme-color-a;
						text-align: center;
						font-size: 28rpx;
						border-radius: 40rpx;
						color: #fff;
					}
				}
			}
		}

		.popup-box {
			width: 583rpx;
			height: 580rpx;
			border-radius: 20rpx;
			box-sizing: border-box;
			background: #fff;
			background: url('../../static/img/me-32.png') no-repeat;
			background-size: cover;
			overflow: hidden;
			
			.popup-title {
				font-size: 32rpx;
				color: #333;
				font-weight: bold;
				text-align: center;
				margin-top: 224rpx;
			}

			.popup-sub {
				margin-top: 36rpx;
				height: 80rpx;
				padding: 0 50rpx;
				
				view {
					height: 100%;
					padding: 0 40rpx;
					background: #F4F4F4;
				}
				input {
					height: 100%;
					font-size: 24rpx;
					background: #F4F4F4;
				}
			}

			.popup-footer {
				display: flex;
				justify-content: space-between;
				margin-top: 50rpx;
				padding: 0 50rpx;

				.cancle {
					width: 200rpx;
					line-height: 76rpx;
					text-align: center;
					border: 2rpx solid #3F93FF;
					border-radius: 40rpx;
				}

				.confim {
					width: 200rpx;
					line-height: 76rpx;
					text-align: center;
					border-radius: 40rpx;
					background: #3F93FF;
					color: #fff;
				}
			}
		}
	}
</style>